//1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld %lld %lld",&n,&l,&r);
	if(r-l+1>=n) printf("%lld",n-1);
	else{
		ll x=l%n,y=r%n;
		if(x<=y) printf("%lld",y);
		else printf("%lld",n-1);
	}
	return 0;
} 
